package com.yxjx.duoxue.datamodel;

import java.io.Serializable;

import org.json.JSONException;
import org.json.JSONObject;

import com.yxjx.duoxue.utils.UIHelper;

public class DMLocationPoint implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1846268605971535596L;
	// {\"provinceId\":0,\"provinceName\":null,\"cityId\":0,\"cityName\":null,\"zoneId\":0,\"zoneName\":null,\"address\":\"北京市朝阳区望京广顺北大街19号（六佰本）2层B06\",\"business\":\"来广营,望京\",\"gps\":\"116.47365263074,40.012982034307\",\"lng\":\"116.47365263074\",\"lat\":\"40.012982034307\"}
	private int provinceId;
	private String provinceName;
	private int cityId;
	private int zoneId;
	private String zoneName;
	private String address;
	private String gps;
	
	public static DMLocationPoint from(String str) {
		if (UIHelper.isEmpty(str)) {
			return null;
		}
		
		DMLocationPoint point = new DMLocationPoint();
		try {
			JSONObject jo = new JSONObject(str);
			point.provinceId = (Integer) jo.get("provinceId");
			point.provinceName = (String) jo.getString("provinceName");
			point.cityId = (Integer) jo.get("cityId");
			point.zoneId = (Integer) jo.get("zoneId");
			point.zoneName = (String) jo.getString("zoneName");
			point.address = (String) jo.getString("address");
			point.gps = (String) jo.getString("gps");
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return point;
	}
	
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("provinceId = " + provinceId + "\n");
		sb.append("provinceName = " + provinceName + "\n");
		sb.append("cityId = " + cityId + "\n");
		sb.append("zoneId = " + zoneId + "\n");
		sb.append("zoneName ＝ " + zoneName + "\n");
		sb.append("address = " + address + "\n");
		sb.append("gps = " + gps + "\n");
		return sb.toString();
	}

	public int getProvinceId() {
		return provinceId;
	}

	public void setProvinceId(int provinceId) {
		this.provinceId = provinceId;
	}

	public String getProvinceName() {
		return provinceName;
	}

	public void setProvinceName(String provinceName) {
		this.provinceName = provinceName;
	}

	public int getCityId() {
		return cityId;
	}

	public void setCityId(int cityId) {
		this.cityId = cityId;
	}

	public int getZoneId() {
		return zoneId;
	}

	public void setZoneId(int zoneId) {
		this.zoneId = zoneId;
	}

	public String getZoneName() {
		return zoneName;
	}

	public void setZoneName(String zoneName) {
		this.zoneName = zoneName;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getGps() {
		return gps;
	}

	public void setGps(String gps) {
		this.gps = gps;
	}
}
